package start.demo01.inherit;

import org.junit.Test;

import java.io.BufferedInputStream;
import java.io.FileInputStream;

public class Main {

    @Test public void testSon2(){
        Son2 son2=new Son2();
        Son son=new Son();
        //隔代继承不了protected
    }
    Inter in=new Inter(){
        @Override
        public void test(Integer i) {
//            new BufferedInputStream(new FileInputStream(""))
        }
    };
    public void Main(){
        System.out.println("类同名方法");
    }
    public static void main(String[] args){
        //Abstract a=new Abstract(){};
        Sup s=new Son();
        //System.out.println(s.getSs());
        s.show();//静态方法不会被覆盖，父类引用在编译期就决定调用父类自己的方法
//        int a=0,b=2;
//        System.out.println(a=b);

        //Sup.tt t= new Sup.tt();
        //s.getS();
//        Main m=new Main();
//        Inter in=new InterSon();
//         m.get(in);
//         byte a=1;
//           Double c=100.;
//         System.out.println(c);
//        int c=10;
//        m.test(c);
//        m.in(i->System.out.println(i));
    }

    public void in(Inter in){
        in.test(1);
    }
    public void test(int a){
        //int c=0;
        class aa{
            public void get(){
                //a++;
                System.out.println(a);
            }
        }
        new aa().get();
    }

    public void get(Inter i){
        System.out.println("one:"+i);
    }
    public void get(InterSon i){
        System.out.println("two:"+i);
    }
    @Test public void synTest() throws InterruptedException {
//        ExecutorService pool= Executors.newFixedThreadPool(4);
//        pool.execute(()->new Son().add());
//        pool.execute(()->new Son().add());
//        pool.execute(()->new Son().add());
        Sup sup=new Sup();
        Thread t1=new Thread(()->sup.add());
        Thread t2=new Thread(()->sup.add());
        Thread t3=new Thread(()->sup.add());
        t1.start();
        t2.start();
        t3.start();
        //Thread.sleep(3000);
        System.out.println(sup.getCount());
    }
    @Test public void t0(){//对象类型匹配
       Sup s2=new Son2();
       System.out.println(s2 instanceof Son2);//true
       System.out.println(s2 instanceof Sup);//true
       System.out.println(s2 instanceof Son);//false
       System.out.println(s2.getClass().equals(Son2.class));//true
       System.out.println(s2.getClass().equals(Sup.class));//false
       System.out.println(s2.getClass().equals(Son.class));//false
    }
}
